<html>
<head>
	<meta charset="UTF-8">
	<title>usercontroller</title>
</head>
<body>
	<?php 
require 'Admin/Model/UserModel.php';
require 'Controller.php';
class UserController extends Controller{
function __construct(){
parent::__construct();
}
function listusers(){
	$model=new UserModel();
	$data=$model->getUserList();
	
	$this->assign('users',$data);

	$this->display();
	//return $data;

}
function deluser(){
	$uid=$_GET['uid'];
	$model= new UserModel();
	$result=$model->delUser($uid);
	if($result){
echo "<h2>删除成功！3秒后跳转回用户列表页</h2>";
header("refresh:3;url='admin.php?c=user&m=listusers'");
	}
	else{
echo "<h2>删除失败！</h2>";
echo "<a href='admin.php?c=user&m=listusers'>返回列表</a>";
	}
}
function reguser(){
$this->display();
	
}

function adduser(){
	$data=$_POST;
	$file=$_FILES;
	$model=new UserModel();
	$result=$model->adduser($data,$file);
	if ($result) {
		echo "注册成功，3秒后返回用户列表页。";
		header("refresh:3;url='admin.php?c=user&m=listusers'");
	}else{
		echo "注册失败，3秒后返回注册页重新注册。";
		header("refresh:3;url='admin.php?c=user&m=reguser'");
	}



}
function edituser(){
	$uid=$_GET['uid'];
	$model=new UserModel();
	$data=$model->edituser($uid);
	$this->assign('user',$data);
	$this->display();
}
function updateuser(){
	$data=$_POST;
	$file=$_FILES;
	$model=new UserModel();
	$result=$model->updateuser($data,$file);
	if($result){
echo "<h2>修改成功！3秒后跳转回用户列表页</h2>";
header("refresh:3;url='admin.php?c=user&m=listusers'");
	}
	else{
echo "<h2>修改失败！</h2>";
echo "<a href='admin.php?c=user&m=listusers'>返回列表</a>";
	}
}

}

	 ?>
</body>
</html>